<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:sijyp="http://java.sun.com/jsf/composite/sijyp"
	xmlns:a="http://xmlns.jcp.org/jsf/passthrough"
	xmlns:ui="http://java.sun.com/jsf/facelets">
	<rich:panel id="relacionJuridicaContainer" style="border:none;">

		<ui:param name="disableRelacionJuridicaFields"
			value="#{bienPersonaRelacionadaManager.reading or bienManager.reading}" />

		<script type="javascript">
addTextAreaCounterByClass();</script>
		<br />

		<h:panelGrid columns="4" width="100%"
			columnClasses="firstColumnStyle, , , ">
			<ui:include src="/general/topBienesFormsFields.xhtml">


				<ui:param name="etapaGestionValue"
					value="#{bienPersonaRelacionadaManager.relacionJuridica.bien.tpEtapaGestion.nombre}" />
				<ui:param name="requiredEtapaGestion" value="false" />
				<ui:param name="disabledEtapaGestion" value="true" />
				<ui:param name="prepId" value="relacionJuridica" />
			</ui:include>
		</h:panelGrid>

		<hr />
		<br />
		

		<h:panelGrid columns="4" width="100%" columnClasses="tenenciaFirstColumn, , , ">

			<h:panelGrid columns="2">
				<h:panelGrid>
					<h:outputLabel
						value="${msg['bienes.situacion.relacionJuridica.tipoDeRelacion']}" />
				</h:panelGrid>
				<h:outputLabel value="*"
					rendered="#{not disableRelacionJuridicaFields}" />
			</h:panelGrid>
			<h:panelGrid>
				<h:selectOneMenu id="tipoRelacionJuridicaCB"
					value="#{bienPersonaRelacionadaManager.relacionJuridica.tpRelacionjuridicabien.tpRelacionjuridica}"
					disabled="#{disableRelacionJuridicaFields}"
					requiredMessage="${msg['general.requerido']}"
					validatorMessage="${msg['general.requerido']}">
					<f:selectItems value="#{applicationBean.tpRelacionJuridicaBiens}" />
				</h:selectOneMenu>
				<h:message for="tipoRelacionJuridicaCB"
					errorClass="validationErrorMessage" showSummary="false" />
			</h:panelGrid>

			<h:panelGrid columns="2">
				<h:outputLabel
					value="${msg['bienes.situacion.relacionJuridica.fechaRelacion']}" />
				<h:outputLabel value="*"
					rendered="#{not disableRelacionJuridicaFields}" />
			</h:panelGrid>
			<h:panelGrid>
				<rich:calendar id="fechaRelacionJuridica"
					value="#{bienPersonaRelacionadaManager.relacionJuridica.fchRelacion}"
					requiredMessage="${msg['general.requerido']}"
					disabled="#{disableRelacionJuridicaFields}"
					datePattern="dd/MM/yyyy" defaultTime="00:00:00"
					dayClassFunction="obtenerEstiloDisabled"
					dayDisableFunction="deshabilitarDiaPosterior" rendered="true"
					boundaryDatesMode="hidden" />
				<h:message for="fechaRelacionJuridica"
					errorClass="validationErrorMessage" showSummary="false" />
			</h:panelGrid>
		</h:panelGrid>
		
		
		<h:panelGrid id="personaRelField" columns="4" width="100%" columnClasses="tenenciaFirstColumn, , , ">
			<h:panelGrid >
				<h:outputLabel value="${msg['bienes.situacion.relacionJuridica.persona']}*" />
			</h:panelGrid>
			
			<h:panelGrid columns="5">
				<sijyp:personasField prefixId="personaRelacionadaPrefix"
					required="true"
					label=""
					requiredMessage="${msg['general.requerido']}"
					value="#{bienPersonaRelacionadaManager.personaDto.nombre}"
					dto="#{bienPersonaRelacionadaManager.personaDto}"
					styleClass="long longPersona"
					disabled="#{disableRelacionJuridicaFields}" />
			</h:panelGrid>

		</h:panelGrid>

		<h:panelGrid columns="2" columnClasses="tenenciaFirstColumn, ">
			<h:panelGrid columns="2">
				<h:outputLabel
					value="${msg['bienes.situacion.relacionJuridica.observaciones']}" />
				<h:outputLabel value="*" rendered="false" />
			</h:panelGrid>
			<h:panelGrid>
				<h:inputTextarea id="observacionesRelacionJuridica"
					value="#{bienPersonaRelacionadaManager.relacionJuridica.observaciones}"
					style="width:100%" styleClass="long count250" rows="4"
					disabled="#{disableRelacionJuridicaFields}"
					a:maxlength="250">
					<f:validateLength maximum="250" />
				</h:inputTextarea>
			</h:panelGrid>
		</h:panelGrid>

		<br />
		<br />

		
		<h:outputLabel
			value="${msg['bienes.situacion.relacionJuridica.soporteDeRelacionJuridica']}"
			styleClass="subtitle" />
		<hr width="100%" />
		<ui:remove>File upload</ui:remove>
		<sijyp:fileUploadSijyp isReading="#{disableRelacionJuridicaFields}"
			tiposDocumentos="#{applicationBean.tipoDocumentoRelacionJuridicas}"
			required="false"
			bean="#{bienPersonaRelacionadaManager.fileUploadBean}"
			labelUpload="${msg['bienes.situacion.relacionJuridica.anexo']}" />

		<h:panelGroup style="text-align:center;" layout="block">
			<h:commandButton rendered="#{not disableRelacionJuridicaFields}"
				action="#{bienPersonaRelacionadaManager.guardar}"
				value="#{bienPersonaRelacionadaManager.creating ? msg['boton.adicionar'] : (bienPersonaRelacionadaManager.updating ? msg['boton.modificar'] : '')}">
				<f:ajax execute="@this relacionJuridicaContainer"
					render=":sijypMessages relacionJuridicaContainer" />
			</h:commandButton>
			<h:commandButton value="${msg['boton.cancelar']}"
				rendered="#{not bienManager.reading}"
				action="#{bienPersonaRelacionadaManager.init}">
				<f:ajax render="relacionJuridicaContainer :sijypMessages"
					execute="@this" />
			</h:commandButton>
		</h:panelGroup>

		<br />
		<ui:include src="relacionJuridicaTable.xhtml" />
	</rich:panel>
</ui:composition>
